<template>
  <div>
    <div>
      <div>
        <mt-field label="任务类型"
                  placeholder="请选择任务类型"
                  v-model="formDatas.jobType"
                  readonly>
        </mt-field>
      </div>

      <div>
        <mt-field label="车辆类型"
                  placeholder="请选择车辆类型"
                  v-model="formDatas.carType"
                  readonly>
        </mt-field>
      </div>

      <div>
        <mt-field label="联系人"
                  placeholder="请输入联系人"
                  type="text"
                  v-model="formDatas.contacts"
                  readonly>
        </mt-field>
      </div>

      <div>
        <mt-field label="联系电话"
                  placeholder="请输入联系电话"
                  type="number"
                  v-model="formDatas.telephone"
                  readonly>
        </mt-field>
      </div>

      <div>
        <mt-field label="数量"
                  placeholder="请输入数量"
                  type="text"
                  v-model="formDatas.personCount"
                  readonly>
        </mt-field>
      </div>

      <div>
        <mt-field label="航班/车次"
                  placeholder="请输入航班/车次"
                  type="text"
                  v-model="formDatas.flight"
                  readonly>
        </mt-field>
      </div>

      <div>
        <mt-field label="申请单位"
                  placeholder="请输入申请单位"
                  type="textarea"
                  rows="2"
                  v-model="formDatas.accompanyPerson"
                  readonly>
        </mt-field>
      </div>

      <div>
        <mt-field label="公务说明"
                  placeholder="请输入公务说明"
                  type="textarea"
                  rows="2"
                  v-model="formDatas.workDescription"
                  readonly>
        </mt-field>
      </div>

      <div>
        <mt-field label="开始时间"
                  placeholder="请选择开始时间"
                  type="text"
                  v-model="formDatas.startTime"
                  readonly>
        </mt-field>
      </div>

      <div>
        <mt-field label="结束时间"
                  placeholder="请选择结束时间"
                  type="text"
                  v-model="formDatas.desTime"
                  readonly>
        </mt-field>
      </div>

      <div>
        <mt-field label="出发地点"
                  placeholder="请输入出发地点"
                  type="text"
                  v-model="formDatas.startPlace"
                  readonly>
        </mt-field>
      </div>

      <div>
        <mt-field label="详细地址"
                  placeholder="请输入出发地点详细地址"
                  type="textarea"
                  v-model="formDatas.startAddress"
                  readonly>
        </mt-field>
      </div>

      <div>
        <mt-field label="目的地点"
                  placeholder="请输入目的地点"
                  type="text"
                  v-model="formDatas.destination"
                  readonly>
        </mt-field>
      </div>

      <div>
        <mt-field label="详细地址"
                  placeholder="请输入目的地点详细地址"
                  type="textarea"
                  v-model="formDatas.desAddress"
                  readonly>
        </mt-field>
      </div>

      <div>
        <mt-field label="备注"
                  placeholder="请输入备注"
                  type="textarea"
                  rows="4"
                  v-model="formDatas.remark"
                  readonly>
        </mt-field>
      </div>

    </div>
  </div>
</template>

<script>
import { Field, Button, Cell, Toast } from 'mint-ui'
import Filters from 'common/flters'
// import EnumJson from 'common/enumJson'
import ComFetch from 'common/fetch'
import moment from 'moment'
export default {
  name: 'Content',
  components: {
    [Field.name]: Field,
    [Button.name]: Button,
    [Cell.name]: Cell,
    [Toast.name]: Toast
  },
  props: {
  },
  data () {
    return {
      dateName: '',
      formData: { // 表单数据
        jobType: '',
        carType: '',
        reviewStatus: 5,
        workInfoId: '',
        workName: '',
        contacts: '',
        telephone: '',
        personCount: '',
        flight: '',
        accompanyPerson: '',
        startTime: '',
        startTimeRes: '',
        desTime: '',
        desTimeRes: '',
        workDescription: '',
        startPlace: '',
        startAddress: '',
        destination: '',
        desAddress: '',
        remark: '',
        startType: 1,
        desType: 1,
        status: 1
      }
    }
  },
  computed: {
    formDatas () {
      let formData = this.formData
      formData.jobType = Filters.jobType(formData.jobType)
      let carType = formData.carType || 1
      formData.carType = Filters.carTypeInfo(Number(carType))
      formData.startTime = moment(formData.startTime).format('YYYY-MM-DD HH:mm')
      formData.desTime = moment(formData.desTime).format('YYYY-MM-DD HH:mm')
      return formData
    }
  },
  methods: {
    findCarJobsByJobId () {
      let jobId = this.$route.params.jobId
      ComFetch.post('/phone/myApproval/findCarJobsByJobId', { 'jobId': jobId })
        .then(res => {
          let data = res.data
          if (data.code === 1) {
            // console.log(data)
            let content = JSON.parse(data.content)
            this.formData = content
          }
        })
        .catch(res => { })
    }
  },
  mounted () {
    this.findCarJobsByJobId()
  }
}
</script>

<style lang="stylus" scoped>
.popup-w
  width: 100%
</style>
